package com.sm.controller;

import com.sm.app.SmApp;
import com.sm.config.ChatModels;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/ai")
public class AiController {

    @Resource
    private SmApp smApp;

    @Autowired
    private ChatModels chatModelsClient;

    @GetMapping("/sm/chat/sync")
    public String doChatWithSmAppSync(String message,String sessionId, String chatId) {
        String llmChat = smApp.doChat(message, chatId);
        log.info("llmChat: {}", llmChat);
        return null;
    }

    @GetMapping("/sm")
    public String doChat(String message) {
        org.springframework.ai.chat.model.ChatModel dashScopeChatModel = chatModelsClient.deepseekChatModel();
        String call1 = chatModelsClient.alibabaChatModel().call(message);
        String call = dashScopeChatModel.call(message);
        log.info("call: {}", call);
        log.info("call1: {}", call1);
        return call;
    }
}
